namespace Angelus.Oracle.Entity.OracleClient
{
    using System.ComponentModel;
    using System.Data;
    using System.Data.Common;
    using System.Transactions;
    using global::Oracle.DataAccess.Client;
    using IsolationLevel=System.Data.IsolationLevel;

    /// <summary>
    /// Description of DbOracleConnection.
    /// </summary>
    public class DbOracleConnection : DbConnection
    {
        #region Fields

        private DbConnection _connection;

        #endregion

        #region Constructors

        /// <summary>
        /// 
        /// </summary>
        public DbOracleConnection()
        {
            this._connection = new OracleConnection();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        public DbOracleConnection(string connectionString)
        {
            this._connection = new OracleConnection(connectionString);
        }

        #endregion

        #region DbConnection Overrides

        /// <summary>
        /// 
        /// </summary>
        public override string ConnectionString
        {
            get { return this._connection.ConnectionString; }
            set { this._connection.ConnectionString = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override int ConnectionTimeout
        {
            get { return this._connection.ConnectionTimeout; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override string Database
        {
            get { return this._connection.Database; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override string DataSource
        {
            get { return this._connection.DataSource; }
        }

        /// <summary>
        /// 
        /// </summary>
        protected override DbProviderFactory DbProviderFactory
        {
            get { return DbOracleFactory.Instance; }
        }

        /// <summary>
        /// 
        /// </summary>
        internal DbConnection InnerConnection
        {
            get { return this._connection; }
            set { this._connection = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override string ServerVersion
        {
            get { return this._connection.ServerVersion; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override ISite Site
        {
            get { return this._connection.Site; }
            set { this._connection.Site = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override ConnectionState State
        {
            get { return this._connection.State; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="isolationLevel"></param>
        /// <returns></returns>
        protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
        {
            return this._connection.BeginTransaction(isolationLevel);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="databaseName"></param>
        public override void ChangeDatabase(string databaseName)
        {
            this._connection.ChangeDatabase(databaseName);
        }

        /// <summary>
        /// 
        /// </summary>
        public override void Close()
        {
            this._connection.Close();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override DbCommand CreateDbCommand()
        {
            DbCommand command = DbOracleFactory.Instance.CreateCommand();
            command.Connection = this;
            return command;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                this._connection.Dispose();
            }

            base.Dispose(disposing);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="transaction"></param>
        public override void EnlistTransaction(Transaction transaction)
        {
            this._connection.EnlistTransaction(transaction);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override DataTable GetSchema()
        {
            return this._connection.GetSchema();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="collectionName"></param>
        /// <returns></returns>
        public override DataTable GetSchema(string collectionName)
        {
            return this._connection.GetSchema(collectionName);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="collectionName"></param>
        /// <param name="restrictionValues"></param>
        /// <returns></returns>
        public override DataTable GetSchema(string collectionName, string[] restrictionValues)
        {
            return this._connection.GetSchema(collectionName, restrictionValues);
        }

        /// <summary>
        /// 
        /// </summary>
        public override void Open()
        {
            this._connection.Open();
        }

        #endregion
    }
}